home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Education
/
World of Education.iso
/
world_j
/
jabr103.zip
/
TUTORIAL.DOC
< prev
Wrap
Text File
|
1991-04-06
|
13KB
|
413 lines
Tutorial for Al-Jabr V1.03
by Uchenna Ogbuji
This tutorial is very easy to use. Print it out as you will not be
able to view it on screen while Al-Jabr is running. You simply enter the
commands you are asked to and read the commentary on the results. The
commands are denoted by a ">" sign at the beginning of the line. This
symbolises the Al-Jabr command prompt and you should not include it in your
commands. Any text that doesn't have a ">" sign at the beginning of the
line is a comment and should not be entered at the command prompt. You
don't have to try alll the examples and you can skip over any material you
feel you have a good grasp of. At any point you can enter "quit" at the
command prompt and you will be returned to DOS.
Please read readme.doc first as it gives information on Al-Jabr's
minimum requirements and which file you should run.
------------------------------------------------------------
Let us start simple. Al-Jabr has 26 variables you can use, each
denoted by a single letter. You can assign a value to a variable. The
simplest assignment, of course, is just to assign a number:
>v = 3.678
remember that the above line starts with a ">" sign so you should enter "v
= 3.678" at the ">" prompt in Al-Jabr. When you do, Al-Jabr will respond
with "= 3.678". This tells you that the number 3.678 has been successfully
stored in the variable v.
>u = v
now Al-Jabr still reports "= 3.678". Perhaps you have figured it out by
now. The variable v contains the value 3.678 and will always contain that
value until you assign it another value.
>u = v + 6
now the value in v, 3.678, is added to 6 and placed in u. Al-Jabr reports
that 9.678 is assigned to u.
>f = v * 8.6e-3
here v (still 3.678) is multiplied by 8.6e-3 (which is the computer
exponential form for 8.6*10^-3 or .0086) and the result (.0316308) is
placed in f. Al-Jabr has two special stored constants:
>d = :p
you will find 3.14159265 has been assigned to d. Some of you will recognise
this number. It is the ratio pi. :p is a short form of this number for Al-
Jabr. :e is the short form of e (2.718281828), the base of natural
logarithms, also known as Naperian logarithms.
>f = :e ^ 2 + d
will place 10.5306488 in f. There is one more stored constant you will
encounter soon. Let us now explore the functions supported by Al-Jabr:
>y = sin t
should return 0 because since t hasn't been assigned a value yet, it is
assumed to be 0, and the sine of 0 is 0.
>g = 4! + abs (-10)
should return 34. First the factorial of 4 (4*3*2*1) is computed and then
added to the magnitude of -10 (10).
>b = 2 * :p
= 6.28318531
>c = sin (cos b) + atan (log 54)
should return 1.88875426, the sine of the cosine of 2 times pi plus the
arctangent of the base ten logarithm of 54.
>r = sqrt 16
will return 4, the square root of 16. However if you execute
>v = -16
= -16
>r = sqrt v
you will encounter a domain error because Al-Jabr cannot return the square
root of a negative number. For a detailed list of the functions supported
by Al-Jabr, see part I of the manual.
Al-Jabr can compute the sum or product of sequences. I will show you a
few examples so you might figure out what is going on. To sum up all the
integers from 1 to 10, you would enter:
>s = [n=1,10,1,n]
= 55
first the sum is initialised to 0, then n is set to 1 and this is added to
the sum. n is then increased by 1 and this is added to the sum. This keeps
on going until n becomes greater than 10 which is the stop value. Then the
loop ends and the sum is assigned to s. To compute the sum of the squares
of the integers from 1 to 10 you enter:
>c = [m=1,10,1,m^2]
= 385
To sum up the square roots of all the integers from 10 to 100 and then add
50 to the sum enter:
>h = [j=10,100,1,sqrt j] + 50
= 702.156947
Here sum is initialised to 0, j is set to 10 and then the square root is
found and added to the sum. j is then increased by 1 and the process is
repeated until j is greater than 100. Then the sum is added to 50 and
assigned to h. To sum up all the odd numbers from 11 to 25 you could enter:
>v = [l=11,25,2,l]
= 144
here l is increased by 2 at a time rather than 1 thus the above effectively
computes 11 + 13 + 15 + 17 + 19 + 21 + 23 + 25. Note that the start value,
the end value and the increment do not have to be integers:
>s = [f=1.5, 3.5, 0.5, log f]
= 1.89625056
adds log (1.5) + log (2.0) + log (2.5) + log (3.0) + log (3.5) and returns
the sum to s. Finding the product of the sequence is similar except that
you use curly brackets {} instead of square brackets. For instance
>p = {f=1.5,3.5,0.5, log f}
= 0.00547579472
finds log (1.5) * log (2.0) * log (2.5) * log (3.0) * log (3.5) and assigns
the product to p. See the manual for a more detailed coverage of the syntax
and operation of Al-Jabr's sum and product of sequence functions. Now try
something interesting. Enter
>show all
You should see a display of all your variables and their contents. This is
useful when you need to know what the variables contain. You don't have to
display them all to check the value of one, though, if you want to see just
what's in p for instance, you would enter
>show p
p = 0.00547579472
Now try this:
>w = 45 * 2
= 90
>s = :e
= 2.718281828
note that each variable is automatically updated in the display as you
alter it.
Try the following sequence of commands:
>x = 1
= 1
>y = cos (3*x/2) + sin (x/2)
= 0.55016274
>store
cos (3*x/2) + sin (x/2) has been stored as expression #1
>f = #1
= 0.55016274
You will find that f has been assigned the same thing as y. Now try:
>x = :p
= 3.14159265
>z = #1
= 1
Let me explain the above. the store command stores the last expression that
you worked with in memory. It calls the first expression it stores #1, the
second, #2 etc. up to #9. Thus you can store up to 9 expressions in memory
at a time. In the above sequence I stored "cos (3*x/2) + sin (x/2)" as
expression #1. At the time x contained 1 so #1 was evaluated as "cos (3/2)
+ sin (1/2)" and f was assigned 0.5501627, the result. But when I changed x
to pi, the value of #1 changed as well. You can incorporate stored
expressions in to other expressions too. Eg.
>q = #1 ^ 2 + #1 + 3.0
= 5
There is a short-cut for storing expressions:
>store b = 6 * :e - ln 5
= 14.7002531
does exactly the same thing as
>b = 6 * :e - ln 5
>store
You can display stored expressions just as you can stored variables:
>show #1
displays expression #1, while
>show #all
displays all the currently stored expressions. Here's a neat trick: try
>store z = k^2
= 0
k^2 has been stored as expression #3.
>y = {k=2,11,3,#3}
= 774400
does exactly the same thing as
>y = {k=2,11,3,k^2}
= 774400
that is it finds 2^2 * 5^2 *8^2 * 11^2.
If you have a printer connected enter
>print
as you can see the "print" command sends all the variables and stored
expressions to the printer.
Now we finally get to Al-Jabr's graphical capabilities. Let us say we
want to plot the graph of y=4*x^2 + 2*x + 1 between x=-5 and x=5, and
between y=-20 and y=20, we could enter
>plot x;4*x^2 + 2*x + 1;-5,5,-100,100
If we wanted to plot the graph of d=v*cos v between x=-3 and x=5 and
we didn't know the maximum and minimum values of d in this interval, yet we
wanted to show the entire function, we could enter:
>plot v;v*cos v;-3,5
since we didn't specify the range of the vertical axis Al-Jabr
automatically calculates it so that the entire function is shown. Note that
Al-Jabr cannot always compute the maximum and minimum vertical axis values.
For example if you enter
>plot n;log -n;-2,2
Al-Jabr will respond with an error when n becomes 0 and return you to the
command prompt. This is because log 0 is an infinite quantity and Al-Jabr
cannot display infinite quantities! To view the graph of this function you
will have to specify the vertical axis range yourself. For example you
might decide to see the portions of the graph that fall between -6 and 6 on
the vertical axis:
>plot n;log -n;-2,2,-6,6
Note that each time you plotted a new graph the viewing area is
cleared. You can plot a new graph uopn an existing one but you must use the
"over" command. For instance, to show the graph of r=tan (t^2) over the
last graph you plotted enter
>over t;tan (t^2)
and slect any color you would like for the new graph. Note that there are
no axis specifications. Over automatically displays the graph in the same
region as the last one and you shouldn't specify horizontal or vertical
axis ranges. There are 4 colors available to help you differentiate between
graphs. You can keep displaying graphs over and over each other in any
combination of white, grey, cyan and yellow ad infinitum.
Al-Jabr can calculate a polynomial of best statistical fit to a set of
data and plot the graph of the polynomial. This is accomplished with the
"cfit" command. There is a sample file called infile.dat that should have
come with Al-Jabr. If it is in the current directory enter
>cfit infile.dat
You can view the contents of infile.dat at the MSDOS prompt by entering
"type infile.dat". As you will see, infile.dat just consists of several
sets of numbers. These numbers constitute the data that Al-Jabr attempts to
fit a curve to. These data points are shown as small green circles on the
graph. See the manual (part II, subheading "CFIT:") for a description of
the syntax of the data files.
One of Al-Jabr's most useful abilities is its ability to capture its
graphical displays to a .PCX format file. If you have a graph on the screen
right not, try capturing it to a file called sample.pcx with the command
>capture sample.pcx
You can later manipulate sample.pcx as any PCX format file and incorporate
it into other programs.
Al-Jabr's commands are more fully described and explained in the
manual, part II.
Now we shall explore some common error conditions and what might cause
them.
>hello
Error 00: Unrecognized command.
"hello" is not one of the commands that Al-Jabr understands.
>plot 3*d;0,10
Error 01: Syntax error in command.
The independent variable wasn't specified and thus Al-Jabr couldn't plot
the graph you requested.
>plot d;3*d;0,10
should work. Some errors have mathematical causes:
>store y = acos -4
Error 03: The argument to acos is out of its domain.
the argument to the arccosine function must be between -1 and +1.
>x = 0
= 0
>z = 5 + 6/x
Error 06: Division by zero.
Division by zero yields an infinite quantity, which Al-Jabr cannot handle.
>h = 3.45e -3
Error 07: Syntax error in expression.
No spaces are permitted whithin a number. Try
>h = 3.45e-3
Some errors are more subtle:
>plot x;3 - 2*x^2;3,-5
Error 11: Invalid horizontal axis range.
the minimum horizontal axis value (3) cannot be greater than the maximum (-
5)!
>plot x;3 - 2*x^2;-5,3
should work.
Well by now you should have obtained a working knowledge of the
functioning of Al-Jabr. You might want to experiment some on your own. If
not you can enter
>quit
at the command prompt to exit to dos. For a more detailed guide to using
Al-Jabr, I'd advise you to read the manual. If you encounter a problem and
need to contact me, read the readme.doc file. I hope you enjoy using Al-
Jabr. I welcome any constructive suggestions and criticisms of the program,
manual, or this tutorial.